package com.by.auto.interceptor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

public class WebMvcConfig implements WebMvcConfigurer {

    @Autowired(required = false)
    TokenInterceptor tokenInterceptor;

    @Autowired(required = false)
    ValidationProperties properties;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(tokenInterceptor)
                .addPathPatterns(properties.getPathPatterns()) //拦截的路径
                .excludePathPatterns(properties.getExcludePathPatterns());
    }
}
